package com.fone.player.play.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.fone.player.ApplicationManage;
import com.fone.player.R;
import com.fone.player.client.DramaRst.Cnts;
import com.fone.player.play.FonePlayerActivity;

/**
 * 剧集指示器item的adapter
 * 
 * @author kongxiaojun
 * @since 2014-4-21
 */
public class GridSeriesTabItemAdapter extends BaseAdapter {

	private List<Cnts> cntsList;
	private boolean fullScreen;

	public GridSeriesTabItemAdapter(List<Cnts> cntsList,boolean fullScreen) {
		super();
		this.cntsList = cntsList;
		this.fullScreen = fullScreen;
	}

	@Override
	public int getCount() {
		if (cntsList == null) {
			return 0;
		}
		return cntsList.size();

	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Cnts cnts = cntsList.get(position);
		ViewHolder holder;
		if (convertView == null) {
			convertView = LayoutInflater.from(ApplicationManage.getGlobalContext()).inflate(R.layout.video_series_tab_item, null);
			holder = new ViewHolder((TextView) convertView.findViewById(R.id.video_series_item_tab_name));
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (cnts.isChecked) {
			holder.seriesTabName.setTextColor(ApplicationManage.getGlobalContext().getResources().getColor(R.color.video_info_tab_line));
		} else {
			if(fullScreen){
				holder.seriesTabName.setTextColor(ApplicationManage.getGlobalContext().getResources().getColor(R.color.white));
			}else {
				holder.seriesTabName.setTextColor(ApplicationManage.getGlobalContext().getResources().getColor(R.color.video_title_bar_title_textcolor));
			}
		}
		
		holder.seriesTabName.setText(cnts.name);
		convertView.setTag(holder);
		return convertView;

	}

	class ViewHolder {
		public TextView seriesTabName;

		public ViewHolder(TextView seriesTabName) {
			super();
			this.seriesTabName = seriesTabName;
		}
	}

	public void setData(List<Cnts> cntsList){
		this.cntsList = cntsList;
		notifyDataSetChanged();
	}
}
